/**
 *
 * MobileLib   
 * TagListActivity.java
 * Jan 16, 2012
 * @author qidiven
 *
 */
package com.ustc.mobilelib.view;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import com.ustc.diven.model.R;
import com.ustc.mobilelib.model.DataCenter;

public class TagListActivity extends Activity{
	
	private TextView tag1 = null;
	private TextView tag2 = null;
	private TextView tag3 = null;
	private TextView tag4 = null;
	private TextView tag5 = null;
	private TextView tag6 = null;
	private TextView tag7 = null;
	private TextView tag8 = null;
	private TextView tag9 = null;
	private TextView tag10 = null;
	private TextView tag11 = null;
	private TextView tag12 = null;
	private TextView tag13 = null;
	private TextView tag14 = null;
	private TextView tag15 = null;
	private TextView tag16 = null;
	private TextView tag17 = null;
	private TextView tag18 = null;
	private TextView tag19 = null;
	private TextView tag20 = null;
	

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		DataCenter.getInstance().getTagBuffer().clear();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.taglist);
		init();
	}
	
	private void init()
	{
		this.getWindow().setBackgroundDrawableResource(R.color.loading_bg);
		tag1 = (TextView) findViewById(R.id.textView1);
		tag2 = (TextView) findViewById(R.id.textView2);
		tag3 = (TextView) findViewById(R.id.textView3);
		tag4 = (TextView) findViewById(R.id.textView4);
		tag5 = (TextView) findViewById(R.id.textView5);
		tag6 = (TextView) findViewById(R.id.textView6);
		tag7 = (TextView) findViewById(R.id.textView7);
		tag8 = (TextView) findViewById(R.id.textView8);
		tag9 = (TextView) findViewById(R.id.textView9);
		tag10 = (TextView) findViewById(R.id.textView10);
		tag11 = (TextView) findViewById(R.id.textView11);
		tag12 = (TextView) findViewById(R.id.textView12);
		tag13 = (TextView) findViewById(R.id.textView13);
		tag14 = (TextView) findViewById(R.id.textView14);
		tag15 = (TextView) findViewById(R.id.textView15);
		tag16 = (TextView) findViewById(R.id.textView16);
		tag17 = (TextView) findViewById(R.id.textView17);
		tag18 = (TextView) findViewById(R.id.textView18);
		tag19 = (TextView) findViewById(R.id.textView19);
		tag20 = (TextView) findViewById(R.id.textView20);
		
		tag1.setTextSize(getRandowTextSize());
		tag2.setTextSize(getRandowTextSize());
		tag3.setTextSize(getRandowTextSize());
		tag4.setTextSize(getRandowTextSize());
		tag5.setTextSize(getRandowTextSize());
		tag6.setTextSize(getRandowTextSize());
		tag7.setTextSize(getRandowTextSize());
		tag8.setTextSize(getRandowTextSize());
		tag9.setTextSize(getRandowTextSize());
		tag10.setTextSize(getRandowTextSize());
		tag11.setTextSize(getRandowTextSize());
		tag12.setTextSize(getRandowTextSize());
		tag13.setTextSize(getRandowTextSize());
		tag14.setTextSize(getRandowTextSize());
		tag15.setTextSize(getRandowTextSize());
		tag16.setTextSize(getRandowTextSize());
		tag17.setTextSize(getRandowTextSize());
		tag18.setTextSize(getRandowTextSize());
		tag19.setTextSize(getRandowTextSize());
		tag20.setTextSize(getRandowTextSize());
		tag1.setTextColor(getRandowTextColor());
		tag2.setTextColor(getRandowTextColor());
		tag3.setTextColor(getRandowTextColor());
		tag4.setTextColor(getRandowTextColor());
		tag5.setTextColor(getRandowTextColor());
		tag6.setTextColor(getRandowTextColor());
		tag7.setTextColor(getRandowTextColor());
		tag8.setTextColor(getRandowTextColor());
		tag9.setTextColor(getRandowTextColor());
		tag10.setTextColor(getRandowTextColor());
		tag11.setTextColor(getRandowTextColor());
		tag12.setTextColor(getRandowTextColor());
		tag13.setTextColor(getRandowTextColor());
		tag14.setTextColor(getRandowTextColor());
		tag15.setTextColor(getRandowTextColor());
		tag16.setTextColor(getRandowTextColor());
		tag17.setTextColor(getRandowTextColor());
		tag18.setTextColor(getRandowTextColor());
		tag19.setTextColor(getRandowTextColor());
		tag20.setTextColor(getRandowTextColor());
		
		tag1.setText(DataCenter.getInstance().getTagBuffer().get(0).getTagName());
		tag2.setText(DataCenter.getInstance().getTagBuffer().get(1).getTagName());
		tag3.setText(DataCenter.getInstance().getTagBuffer().get(2).getTagName());
		tag4.setText(DataCenter.getInstance().getTagBuffer().get(3).getTagName());
		tag5.setText(DataCenter.getInstance().getTagBuffer().get(4).getTagName());
		tag6.setText(DataCenter.getInstance().getTagBuffer().get(5).getTagName());
		tag7.setText(DataCenter.getInstance().getTagBuffer().get(6).getTagName());
		tag8.setText(DataCenter.getInstance().getTagBuffer().get(7).getTagName());
		
		tag9.setText(DataCenter.getInstance().getTagBuffer().get(8).getTagName());
		tag10.setText(DataCenter.getInstance().getTagBuffer().get(9).getTagName());
		tag11.setText(DataCenter.getInstance().getTagBuffer().get(10).getTagName());
		tag12.setText(DataCenter.getInstance().getTagBuffer().get(11).getTagName());
		
		tag13.setText(DataCenter.getInstance().getTagBuffer().get(12).getTagName());
		tag14.setText(DataCenter.getInstance().getTagBuffer().get(13).getTagName());
		
		tag15.setText(DataCenter.getInstance().getTagBuffer().get(14).getTagName());
		tag16.setText(DataCenter.getInstance().getTagBuffer().get(15).getTagName());
		
		tag17.setText(DataCenter.getInstance().getTagBuffer().get(16).getTagName());
		tag18.setText(DataCenter.getInstance().getTagBuffer().get(17).getTagName());
		tag19.setText(DataCenter.getInstance().getTagBuffer().get(18).getTagName());
		tag20.setText(DataCenter.getInstance().getTagBuffer().get(19).getTagName());
		
	}
	
	private float getRandowTextSize()
	{
		float result = (float) ((float) (Math.random() % 20) + Math.random() * 10 + 10);
		
		System.out.println("random text size" + result);
		
		return result;
	}
	
	private int getRandowTextColor()
	{
		int result = 0;
		int colorID = (int) (Math.random() * 10 % 7);
		System.out.println("random text color id:" + colorID);
		result = this.getResources().getColor(getColorID(colorID));
		return result;
	}
	
	private int getColorID(int colorID)
	{
		int result = 0;
		switch(colorID)
		{
		case 0:
			result = R.color.tagColor1;
			break;
		case 1:
			result = R.color.tagColor2;
			break;
		case 2:
			result = R.color.tagColor3;
			break;
		case 3:
			result = R.color.tagColor4;
			break;
		case 4:
			result = R.color.tagColor5;
			break;
		case 5:
			result = R.color.tagColor6;
			break;
		case 6:
			result = R.color.tagColor6;
			break;
		}
		return result;
		
	}

}
